package com.zuo.demo01.service.impl;


import com.zuo.demo01.dao.CommentMapper;
import com.zuo.demo01.pojo.Comment;
import com.zuo.demo01.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<Comment> findAll(Map<String, Integer> map) {
        return commentMapper.findAll(map);
    }

    @Override
    public List<Comment> findByBlog(Map<String, Object> map) {
        return commentMapper.findByBlog(map);
    }

    @Override
    public int count() {
        return commentMapper.count();
    }

    @Override
    public int countByBlog(int id) {
        return commentMapper.countByBlog(id);
    }

    @Override
    public int insert(Map<String, Object> map) {
        Date date = new Date(System.currentTimeMillis());
        map.put("commentTime",date);
        map.put("status",0);
/*        map.put("ip","1.1.1.1");
        map.put("replyContent","无");
        map.put("replyTime",date);*/

        return commentMapper.insert(map);
    }

    @Override
    public int verify(int id) {
        return commentMapper.verify(id);
    }

    @Override
    public int delete(int id) {
        return commentMapper.delete(id);
    }
}
